package com.hc.controller;

import com.hc.pojo.User;
import com.hc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @date 2021/03/18
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/findId/{id}")
    public ModelAndView queryId(@PathVariable("id") int id, ModelAndView modelAndView) {
        User user = userService.findUserById(id);
        modelAndView.addObject("user", user);
        modelAndView.setViewName("show");
        return modelAndView;
    }
}
